cmake_minimum_required(VERSION 3.10)
project(CDSAL)

message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CMAKE_C_COMPILER_VERSION: ${CMAKE_C_COMPILER_VERSION}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

#output compile file to build dir
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)

#output lib and executable file to bin
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)



# add target a dynamical lib and executable file
add_library(CDSAL SHARED src/dylib.c)
add_executable(test src/test.c)

# 设置可执行文件和共享库都输出到 bin/
set_target_properties(test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set_target_properties(CDSAL PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)


#set sources file location
file(GLOB sources CMAKE_CONFIGURE_DEPENDS include/*.c include/*.h src/*.c)
target_sources(test PUBLIC ${sources})

# Include directories
include_directories(${CMAKE_SOURCE_DIR}/include)